#!/usr/bin/env python
# coding=utf-8
"""
# @Created on : 2016/04/21 8:29
# @Author     : ldf (ldf@eehello.com)
# @Link       : http://www.eehello.com
# @Version    :
# 本程序在python2.7下测试通过
"""
'''
import socket

sk = socket.socket(socket.AF_INET, socket.SOCK_STREAM,0)
ip_port = ('127.0.0.1', 9999)
sk.bind(ip_port)
sk.listen(5)

while 1:
    conn, address = sk.accept()
    buf = conn.recv(1024)
    conn.send("HTTP/1.1 200 OK\r\n\r\n")
    conn.send('hello')
    conn.close()
'''
import SocketServer


class myserver(SocketServer.BaseRequestHandler):
    def setup(self):
        pass

    def handle(self):

        #print self.request
        #print self.client_address
        #print self.server

        conn = self.request
        buf = conn.recv(1024)
        conn.send("HTTP/1.1 200 OK\r\n\r\n")
        conn.send('hello')
        conn.close()



ip_port = ('127.0.0.1', 9999)
sk = SocketServer.ThreadingTCPServer(ip_port,myserver)

sk.serve_forever()